package com.doit.day03.不可变集合

object _04_filter {
  def main(args: Array[String]): Unit = {
    val arr: Array[Int] = Array(1, 2, 3, 4, 5)

    val res: Array[Int] = arr.filter(_ % 2 == 0)

    val stus = Array(
      Student(1,"zss",18,"male"),
      Student(2,"zss",28,"male"),
      Student(3,"zss",38,"female"),
      Student(4,"zss",48,"male"),
      Student(5,"zss",58,"female"),
    )

    val students: Array[Student] = stus.filter(_.age <= 40)

    //要求年龄大于30岁得男性
    stus.filter(student=>student.age>30 && student.gender == "male")

    for (elem <- students) {
      println(elem)
    }

    println(res.mkString(","))

  }
}


case class Student(id:Int,name:String,age:Int,gender:String)
